#pragma once

#include "OctreePublic.h"
#include "Octree.h"
#include "OctreeNode.h"

/** The information needed to determine whether a primitive is visible. */
struct OctreeNodeInfoCompact
{
	OctreeNode* TreeNode;
	OctreeNodeInfoCompact(OctreeNode* node=NULL) : TreeNode(node) {}
};

/** Defines how the primitive is stored in the scene's primitive octree. */
struct FSceneNodeOctreeSemantics
{
	enum { MaxElementsPerLeaf = 16 };
	enum { MinInclusiveElementsPerNode = 7 };
	enum { MaxNodeDepth = 12 };

	__forceinline static BoxCenterAndExtent GetBoundingBox(const OctreeNodeInfoCompact& Element)
	{
		return BoxCenterAndExtent(Element.TreeNode->getBounds());
	}

	__forceinline static bool AreElementsEqual(const OctreeNodeInfoCompact& A, const OctreeNodeInfoCompact& B)
	{
		return A.TreeNode == B.TreeNode;
	}

	__forceinline static void SetElementId(OctreeNodeInfoCompact& Element, FOctreeElementId Id)
	{
		Element.TreeNode->setOctreeID(Id);
	}
};

typedef TOctree<OctreeNodeInfoCompact, FSceneNodeOctreeSemantics> SceneOctree;